<template>
<!--  <h2>会员统计</h2>-->
  <div ref="myChart" style="width: 1000px;height:700px;">

  </div>
</template>

<script>
export default {
  name: "MemberAnalysis",
  data(){
    return{
      headers:this.$cookies.get("token") != null ? this.$cookies.get("token") : '',
      option:{
        title: {
          text: '会员数量统计'
        },
        tooltip: {},
        legend: {
          data: ['数量']
        },
        xAxis: {
          data: []
        },
        yAxis: {},
        series: [
          {
            name: '数量',
            type: 'bar',
            data: []
          }
        ]
      }
    }
  },
  methods:{

    init(){
      if(this.$refs.myChart){
        let myCharts = this.$echarts.init(this.$refs.myChart)
        myCharts.setOption(this.option)
      }

    }
  },
  mounted() {
    this.$axios.get("/api/report/getMemberReport.do",{
      headers:{
        'token':this.headers
      }
    }).then((res)=>{
      console.log(res.data)
      this.option.xAxis.data = res.data.data.months
      this.option.series[0].data = res.data.data.memberCount
      this.init();
    })

    this.$nextTick(() => {

    });
  }
}
</script>

<style scoped>

</style>